# -*- coding: utf-8 -*-
'''
Created on Wed Sep 12 20:58:08 2018
Author: Lucifer yue
To update your source code.
'''

import os
import sys
#import urllib3
import time
#import datetime
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import scipy.stats
from scipy import stats
#import seaborn as sns
import math

class Loettery:
    def __init__(self):
        self.pathe = 'F:\\Demo\\lottery\\'
        self.file_3d = '3d.xls'
        self.file_ssq = 'ssq.xls'

    def load_data(self,file):
        self.df = pd.read_excel(file)
        return self.df

    def format_df(self):
        row_1 = self.df[0:1]
        col_list = self.df.columns.to_list()
        col_dir ={}
        for value in col_list:
            name = self.df.loc[0,value]
            col_dir[value] = name
        #rename(columns={'A':'a', 'B':'b', 'C':'c'}, inplace = True)
        self.df.rename(columns=col_dir,inplace = True)
        #df.drop(index=[0, 1])
        self.df.drop(index=[0],inplace=True)
        self.df.reset_index(0,inplace=True)
        #df.drop(['B', 'C'], axis=1)
        self.df.drop(['index'],axis=1,inplace=True)
        return self.df

if __name__ == '__main__':
    one = Loettery()
    file = one.pathe+one.file_3d
    data_df = one.load_data(file)
    #data_df = one.format_df()
def test_3d(df):
    col_list = ['开','奖','号']
    for ix,value in enumerate(col_list):
        locals()['re'+str(ix)] = data_df[value].value_counts()
    num_list = [n for n in range(0, 10)]
    res_df = pd.DataFrame({'num':num_list,'first': num_list, 'second': num_list, 'third': num_list})
    for ix in num_list:
        res_df.loc[ix,'first'] = re0[ix]
        res_df.loc[ix,'second'] = re1[ix]
        res_df.loc[ix, 'third'] = re2[ix]
    res_df.to_excel('fc3d.xlsx')



# mylist = [1,2,2,2,2,3,3,3,4,4,4,4]
# myset = set(mylist)  #myset是另外一个列表，里面的内容是mylist里面的无重复 项
#
# for item in myset:
#     print("the %d has found %d" %(item,mylist.count(item)))
#ss = Series(['Tokyo', 'Nagoya', 'Nagoya', 'Osaka', 'Tokyo', 'Tokyo'])
#ss.value_counts()   #value_counts 直接用来计算series里面相同数据出现的频率
# mylist =[0]
#
# def mylist (starnum,endnum):
#     starnum = starnum + 1
#     while starnum < endnum:
#         mylist.append(starnum)
#     return mylist()
# dfcount = pd.DataFrame()
#
# columnlist = df.columns
# columnlist = columnlist[3:]
# count_dir={}
# for name in columnlist:
#     name = str(name)
#     locals()[name] = df[name].value_counts()
#     ll = locals()[name].index
#     ll = ll.tolist()
#     for ix in ll:
#         col = name+'频次'
#         pinci = locals()[name][ix]
# #        if pinci == :
# #            pinci = 0
#         dfcount.loc[ix,col] = pinci
        
    #print(locals()[name])
#dfcount.to_excel('双色球数字频次.xlsx')




